import java.lang.reflect.Array;
import java.util.Arrays;



public class Text {
    public static void main(String[] args) {
        int[][] array = {{1,2,3},{4,5,6}};
        
    }







    public static void main10(String[] args) {
        int[] array1 = {1,21,31,3,5};
        int[] array2 = {1,21,31,3,5};
        boolean flg = Arrays.equals(array1,array2);
        System.out.println(flg);

        System.out.println("============");
        int[] array3 = new int[10];
        Arrays.fill(array3,9);
        System.out.println(Arrays.toString(array3));
    }

    public static void bubbleSort(int[] array){
        boolean flg = false;

        for (int i = 0; i < array.length-1; i++) {
            for (int j = 0; j < array.length-1-i; j++) {
                if(array[j] > array[j+1]) {
                    int tmp = array[j];
                    array[j] = array[j + 1];
                    array[j + 1] = tmp;
                    flg = true;
                }
            }
            if(flg = false){
                break;
            }
        }
    }

    public static void main9(String[] args) {
        int[] array = {1,21,31,3,5};
        bubbleSort(array);
        //Arrays.sort(array,2,5);
        System.out.println("排序后的数组："+Arrays.toString(array));

    }


    //二分查找
    public  static int binarySearch(int[] array,int key){
        int left = 0;
        int right = array.length - 1;
        while(left <= right){
            int mid = (left+right)/2;
            if(array[mid] < key){
                left = mid+1;
            } else if (array[mid] == key) {
                return mid;

            }else {
                right = mid - 1;
            }
        }
        return -1;
    }
    public static void main8String[] args) {
        int[] array = {1,2,3,4,5};
        int index = binarySearch(array,3);
        if (index == -1){
            System.out.println("没有找到你要找的数字！");
        }else{
            System.out.println("找到了你要找的数字：");
        }
    }

    public static int find(int[] array,int key){
        for (int i = 0; i < array.length; i++) {
            if(array[i] ==key){
                return i;
            }
        }
        return -1;
    }



    public static void main7(String[] args) {
        int[] array = {1,2,3,4,5};
        int []copy = Arrays.copyOfRange(array,1,3);
        System.out.println(Arrays.toString(copy));
    }



    public static void main6(String[] args) {
        int[] array = {1,2,3,4,5};

        int[] copy = Arrays.copyOf(array,array.length*2);
        array = copy;

        for (int x:copy) {
            System.out.print(x+" ");

        }
        System.out.println();
        System.out.println(Arrays.toString(array));

    }

    public static void main5(String[] args) {
        int[] array = {1,2,3,4,5};
        int[] copy = new int[array.length];

        System.arraycopy(array,0,copy,0,array.length);
        for (int x:array) {
            System.out.print(x+" ");

        }
        System.out.println();


    }

    public static void main4(String[] args) {
        int[] array = {1,2,3,4,5};

        int [] copy = Arrays.copyOf(array,array.length);

        for (int x:copy) {
            System.out.print(x+" ");

        }
        System.out.println();

    }




    public static void main3(String[] args) {
        int[] array = {1,2,3,4,5};
        int [] array2 = array;
        for (int x:array2) {
            System.out.print(x+" ");

        }
        System.out.println();
    }


    public static void main2(String[] args) {
        int[] array = {1,2,3,4,5};

        int[] copy = new int[array.length];
        for (int i = 0; i < array.length; i++) {
            copy[i] = array[i];
        }

        for (int x:copy) {
            System.out.print(x+" ");

        }
        System.out.println();

    }
    
    
    
    public static void main1(String[] args) {
        int[] array = {1,2,3,4,5};
        for (int i = 0; i < array.length; i++) {
            System.out.print(array[i]+" ");

        }
        System.out.println();
        System.out.println("==============");
        for(int x : array){
            System.out.println(x + " ");
        }
        System.out.println();
        System.out.println("================");


        String ret = Arrays.toString(array);
        System.out.println(ret);


    }

}
